package com.yyg.boot.web;

import com.yyg.boot.cache.CacheService;
import com.yyg.boot.domain.User;
import com.yyg.boot.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 一一哥Sun
 * @Date Created in 2020/4/1
 * @Description Description
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserRepository userRepository;

    @PostMapping("/{id}")
    public String saveUser(@PathVariable("id") Integer id) {
        User user = new User();
        user.setId(id);
        user.setName("特没谱");
        user.setSex("女");
        userRepository.save(user);
        return "success";
    }

    @GetMapping("")
    public List<User> getUser() {

        return userRepository.findAll();
    }

}
